﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel.DataAnnotations;
using ueEngine.Biz.Inf.Entities.DBSupport;
using ueEngine.Framework.Exception;
namespace ueEngine.Biz.Inf.Entities
{
    /// <summary>
    /// 招募单
    /// </summary>
    [Table("RecruitSheet")]
    public class RecruitSheet : BaseEntity<RecruitSheet>
    {
        public RecruitSheet() { }
        public override RecruitSheet Get(System.Linq.Expressions.Expression<Func<RecruitSheet, bool>> where)
        {
            using (Context ctx = new Context())
            {
                var item = ctx.RecruitSheet.FirstOrDefault(where);
                if (item != null)
                {
                    this.CustomerManager = item.CustomerManager;
                    this.Id = item.Id;
                    this.PublishDate = item.PublishDate;
                    this.Recruiter = item.Recruiter;
                    this.RecruitSubject = item.RecruitSubject;
                    this.RecruitType = item.RecruitType;
                    this.WorkArea = item.WorkArea;
                    this.WorkAddress = item.WorkAddress;
                    this.Templete = item.Templete;
                    this.Contact = item.Contact;
                    this.ContactPhone = item.ContactPhone;
                    this.EnableEmail = item.EnableEmail;
                    this.Caption = item.Caption;
                    this.DepositCompanyId = item.DepositCompanyId;
                    this.ReceiveEmail = item.ReceiveEmail;
                    this.QQ = item.QQ;
                    this.Refresh = item.Refresh;
                    this.Source = item.Source;
                    this.IsVerify = item.IsVerify;
                    this.MapSetting = item.MapSetting;
                    //this.Description = item.Description;
                    return this;
                }
                return null;
            }
        }
        #region Filed
        [Key]
        [Column("Id", TypeName = "int")]
        [DatabaseGenerated(DatabaseGeneratedOption.Identity)]
        public int Id { get; set; }
        /// <summary>
        /// 招募标题
        /// </summary>
        [Column(TypeName="nvarchar")]
        [StringLength(200)]
        public string Caption { get; set; }       

        /// <summary>
        /// 代理人用户名
        /// </summary>
        [Column("Recruiter",TypeName="nvarchar")]
        [Required]
        [StringLength(200)]
        public string Recruiter { get; set; }
        /// <summary>
        /// 被代理的企业Id
        /// </summary>
        [Required]
        public int DepositCompanyId { get; set; }
        /// <summary>
        /// 招募类型分类
        /// </summary>
        [Column("RecruitType",TypeName="int")]
        [Required]
        public int RecruitType { get; set; }
        /// <summary>
        /// 子类
        /// </summary>
        [Column("RecruitSubject", TypeName = "int")]
        [Required]
        public int RecruitSubject { get; set; }
        /// <summary>
        /// 联系人
        /// </summary>
        [Column(TypeName="nvarchar")]
        public string Contact { get; set; }
        /// <summary>
        /// 联系电话
        /// </summary>
        [Column(TypeName="nvarchar")]
        public string ContactPhone { get; set; }
        /// <summary>
        /// 工作区域
        /// </summary>
        [Column(TypeName="int")]
        public int WorkArea {get;set;}
        /// <summary>
        /// 工作地点
        /// </summary>
        [Column(TypeName="nvarchar")]
        public string WorkAddress { get; set; }
        /// <summary>
        /// 发布日期
        /// </summary>
        [Column("PublishDate",TypeName="datetime")]
        [Required]
        public DateTime PublishDate { get; set; }
        /// <summary>
        /// 执行该委托的客户经理（如果有）
        /// </summary>
        [Column("CustomerManager",TypeName="nvarchar")]
        [StringLength(45)]
        public string CustomerManager { get; set; }
        /// <summary>
        /// 是否为模板
        /// </summary>
        [Column(TypeName="bit")]
        public bool Templete { get; set; }

        /// <summary>
        /// 是否已经审核
        /// </summary>
        [Column(TypeName="bit")]
        public bool IsVerify { get; set; }

        /// <summary>
        /// 是否启用邮件服务
        /// </summary>
        [Column(TypeName = "bit")]
        public bool EnableEmail { get; set; }

        /// <summary>
        /// 用以接收简历的邮箱
        /// </summary>
        [Column(TypeName="varchar")]
        [StringLength(200)]
        public string ReceiveEmail { get; set; }

        [Column(TypeName = "varchar")]
        [StringLength(15)]
        public string QQ { get; set; }

        [Column(TypeName="datetime")]
        public DateTime Refresh { get; set; }

        [Column(TypeName="int")]
        public int Source { get; set; }

        [Column(TypeName="varchar")]
        [StringLength(200)]
        public string MapSetting { get; set; }
        #endregion
    }
}
